#pragma warning(disable : 4996)

#ifdef __GNUC__
#include <string.h> //memcpy in GNU GCC
#endif // __GNUC__

//if( to == NULL ) to = new char[sizeof(from) + 1];

//string copy
#define COPY_CZ(to,from) { strncpy( to, from, sizeof(to) ); to[ sizeof(to) - 1 ] = '\0'; }

//string copy, input(from) is pointer
#define COPY_CZ_POINTERINPUT(to,from) { strncpy( to, from, strlen(to)-1 ); to[ strlen(to) ] = '\0'; }

//memcopy + allocate memory for the dest
#define MEM_COPY(to,from,size) { if( to == NULL ) to = (void*)malloc(size); memcpy(to, from, size; }

//fill error
#define FILL_ERROR(dest, message) { dest = new char[strlen(message)+1]; strcpy(dest, message); dest[ strlen(message) + 1 ] = '\0'; }
